<?php
/*----------------------------------------------------------------------------------------------
Kit Applicatif PHP
Noyau générique d'applications PHP / generic kernel for PHP applications
noyau 0.5 / PHP 4
http://code.fredbird.org/wak

template feeder : django


file version 2005-04-12 12:44:53
----------------------------------------------------------------------------------------------*/

class waktemplateFeeder extends wakCoreComponent {
/*------------------------------------------------------------------------------
                                                                     constructor
------------------------------------------------------------------------------*/
	/**
	*
	* @access
	*/
	function wakTemplateFeeder() {
		$this->__construct();
	}/**/
	
	/**
	* real constructor
	* @access
	*/
	function __construct() {
		//wakNeedClass('djangotpl');
		include_once(WAK_CORE_PATH.'lib/djangotpl/djangotpl.lib.php');
		include_once(WAK_CORE_PATH.'lib/djangotpl/djangotpl-filters.lib.php');
		include_once(WAK_CORE_PATH.'lib/djangotpl/djangotpl-tags.lib.php');
		include_once(WAK_CORE_PATH.'lib/datapath.class.php');
	}/**/
/*------------------------------------------------------------------------------
                                                                  public methods
------------------------------------------------------------------------------*/
	/**
	* feed template with data
	* @param string $template string or file name
	* @param array $data data to inject
	* @access public
	* @return string
	*/
	function feed($template,$data=array()) {
		if (!is_string($template)) {
			trigger_error("templatefeeder-django: template is not typed string but typed ".gettype($template),E_USER_WARNING);
			print_r($template);
			return false;
		}
		//echo "templatefeeder: feeding ".affvar($template,'template')." with ".affvar($data,'data');
		// le template est il un fichier ?
		if (strlen($template)<255 and file_exists($template) and $lines=file($template)) {
			// echo '<p>Parsing '.$template.'</p>';
			$str=join('',$lines);
		} else $str=&$template;
		// building template instance
		$tpl=&new djangoTpl($str);
		// rendering
		if (is_a($data,'datatree'))
			$data=$data->get();
		return $tpl->render($data);
	}/**/
	
	/**
	* 
	* @param
	* @access public
	* @return 
	* /
	function () {
		
	}/**/
/*------------------------------------------------------------------------------
                                                                      properties
------------------------------------------------------------------------------*/
	/**
	* @var type desc
	*/
	//var //
	var $default_parameters=array();
/*------------------------------------------------------------------------------
                                                                 private methods
------------------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access protected
	* @return 
	* /
	function () {
		
	}/**/
	
	/**
	* 
	* @param
	* @access protected
	* @return 
	* /
	function () {
		
	}/**/
/*------------------------------------------------------------------------------
                                                                 private methods
------------------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access private
	* @return 
	* /
	function () {
		
	}/**/
	
	/**
	* 
	* @param
	* @access private
	* @return 
	* /
	function () {
		
	}/**/
}
?>
